

/*---------------------------------------------------------
   Initializes the effect. The data is a table of data 
   which was passed from the server.
---------------------------------------------------------*/
function EFFECT:Init( data )
	
	self.Ent = data:GetEntity()
	if self.Ent == nil or not self.Ent:IsValid() then
		return
	end
	self.Pos = self.Ent:GetShootPos()
	self.Emitter = ParticleEmitter( self.Pos )
	self.Time = CurTime() + .3
	
end

/*---------------------------------------------------------
   THINK
   Returning false makes the entity die
---------------------------------------------------------*/
function EFFECT:Think( )

	if self.Emitter == nil then return false end
	self.Ang = self.Ent:GetAimVector()
	self.Pos = self.Ent:GetShootPos() + (self.Ent:GetRight() * 10) + (self.Ang * 22)
	
	for i=1,6 do
		local particle = self.Emitter:Add("effects/muzzleflash"..math.random(1,4), self.Pos + (self.Ang * math.random(-15,0)) )
		particle:SetVelocity(self.Ang * 100)
		particle:SetDieTime( .3 )
		particle:SetStartAlpha( 150 )
		particle:SetEndAlpha( math.random(200,250) )
		particle:SetStartSize( math.Rand(0,1) )
		particle:SetEndSize( 10 )
		particle:SetRoll( math.Rand( -95, 95 ) )
		particle:SetRollDelta( math.Rand(0,1.4) )
		particle:SetColor( 10, 10, math.random(200,255) )
		
		particle:SetAirResistance( 110 )
		particle:SetCollide( true )
		particle:SetBounce( .1 )
	end
	
	for i=1,math.random(6,8) do
		local particle = self.Emitter:Add("effects/muzzleflash"..math.random(1,4), self.Pos + self.Ang * 10)
		particle:SetVelocity(self.Ang * math.random(400,750) + Vector(math.random(-50,50),math.random(-50,50),10))
		particle:SetDieTime( math.Rand(.7,1.1) )
		particle:SetStartAlpha( math.random( 120, 160 ) )
		particle:SetEndAlpha( 1 )
		particle:SetStartSize( math.random(5,10) )
		particle:SetEndSize( math.random(20,100) )
		particle:SetRoll( math.Rand( -95, 95 ) )
		particle:SetRollDelta( math.Rand(0,1.4) )
		particle:SetColor( math.random( 150, 255 ), math.random( 120, 150 ), 100 )
		
		particle:SetAirResistance( 110 )
		particle:SetCollide( true )
		particle:SetBounce( .4 )
		particle:SetGravity( Vector( 0, 0, math.random(190,250) ) )
	end
	
	if self.Time < CurTime() then self.Emitter:Finish() return false end
	return true
end


/*---------------------------------------------------------
   Draw the effect
---------------------------------------------------------*/
function EFFECT:Render()

end
